#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "symbol.h"

int main(){
	printf("Test 1 - Hash Function\n");
	printf("Hash Value of 'kitty' is: %d \n",  Hash("kitty"));
	printf("Hash Value of 'doggy' is: %d \n",  Hash("doggy"));
	printf("Hash Value of '1361' is: %d \n",  Hash("1361"));
	printf("Hash Value of 'imadasdu' is: %d \n",  Hash("imadasdu"));
	printf("-------------------\n\n");
	printf("Test 2 - init SymbolTable\n");
	SymbolTable *table = initSymbolTable();
	printf("table: %d \n",table);
	printf("-------------------\n\n");
	printf("Test 3 - put Symbol\n");
	SYMBOL *put1 = putSymbol(table, "LOLIPOP", 10);
	SYMBOL *put2 = putSymbol(table, "PHILIP", 10);
	SYMBOL *put3 = putSymbol(table, "FRANZ", 10);
	SYMBOL *put4 = putSymbol(table, "PHILJN", 10);
	printf("Test 3 - continued.. Inserting duplicate \n");
	SYMBOL *put18 = putSymbol(table, "LOLIPOP", 10);
	SYMBOL *put17 = putSymbol(table, "PHILJN", 10);

	printf("-------------------\n\n");
	printf("Test 4 - get Symbol retrieving inserted symbols\n");
	SYMBOL *get1 = getSymbol(table, "LOLIPOP");
	SYMBOL *get2 = getSymbol(table, "PHILIP");
	SYMBOL *get3 = getSymbol(table, "FRANZ");
	SYMBOL *get4 = getSymbol(table, "PHILJN");
	printf("-------------------\n\n");
	printf("Test 5 - scope SymbolTable\n");
	SymbolTable *new1 = scopeSymbolTable(table);
	SymbolTable *new2 = scopeSymbolTable(table);
	SymbolTable *new3 = scopeSymbolTable(new1);
	printf("Test 5 continued.. Inserting symbols into every table \n");
	SYMBOL *put5 = putSymbol(new1, "LOLIP", 10);
	SYMBOL *put6 = putSymbol(new1, "PHILP", 14);
	SYMBOL *put7 = putSymbol(new1, "FRANZ", 1);
	SYMBOL *put8 = putSymbol(new1, "PHILJN", 10);
	SYMBOL *put9 = putSymbol(new2, "LOLI", 16);
	SYMBOL *put10 = putSymbol(new2, "PHIofLP", 12);
	SYMBOL *put11 = putSymbol(new2, "FRAZ", 1);
	SYMBOL *put12 = putSymbol(new2, "PHILN", 10);
	SYMBOL *put13 = putSymbol(new3, "franz", 18);
	SYMBOL *put14 = putSymbol(new3, "pontoppidan", 5);
	SYMBOL *put15 = putSymbol(new3, "Thyssen", 3);
	SYMBOL *put16 = putSymbol(new3, "Michael", 78);	
	printf("Test 5 continued.. getSymbol from root with child new3 \n");
	SYMBOL *get5 = getSymbol(new3, "LOLIPOP");
	printf("Test 5 continued.. getSymbol Trying retrieve a symbol from new1, ");
	printf("however new 2 is given as symboltable. Should return null\n");
	SYMBOL *get6 = getSymbol(new2, "LOLIP");
	printf("-------------------\n\n");	
	printf("Test 6 - dumpSymbolTable \n");
	dumpSymbolTable(new1);
	dumpSymbolTable(new2);
	dumpSymbolTable(new3);

	return 1; 
}
